package com.matt.repository;

import com.matt.controller.api.domin.Thermometer;
import com.matt.domain.UserActiveRegistration;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


public interface UserActiveRegistrationRepository extends JpaRepository<UserActiveRegistration, String>, JpaSpecificationExecutor<UserActiveRegistration> {


//    Long findCountByAreaIdAndActivityId(String areaId, String s);


//    List<UserActiveRegistration> findAllByActivityIdAndAreaId(String activityId, String areaId);
    List<UserActiveRegistration> findAllByActivityIdAndAreaIdAndIsActiveTrue(String activityId, String areaId);
    @Query("SELECT COUNT(uar) FROM UserActiveRegistration uar WHERE uar.areaId = :areaId AND uar.activityId = :activityId AND uar.isActive = true ")
    Long findCountByAreaIdAndActivityId(@Param("areaId") String areaId, @Param("activityId") String activityId);

    void deleteByActivityId(String id);

//    @Query(value = "SELECT COUNT(*) FROM user_active_registration uar WHERE uar.area_id = :areaId AND uar.activity_id = :activityId AND uar.is_active = :isActive", nativeQuery = true)
//    Long findCountByAreaIdAndActivityIdAndIsActive(@Param("areaId") String areaId, @Param("activityId") String activityId, @Param("isActive") boolean isActive);
}
